﻿using System.Collections.Generic;
using System.Windows.Controls;
using WPF_CAD.Model;

namespace WPF_CAD.Strategy
{
    public class PolyLineToolStrategy : StrategyBase
    {
        public PolyLineToolStrategy(IFigure figure) : base(figure)
        { }

        public override IFigure PerformMouseLeftClicDownEvent(Canvas canvas, IPoint point, IEnumerable<IFigure> figures)
        {
            ClickCount++;

            if (ClickCount <= 1)
            {
                ValidateFigureIsNew<PolyLine>();
                Figure.PointsCollection.Add(point);
                return Figure;
            }
            DrawFigureInCanvas(canvas, point);
            return Figure;
        }

        public override IFigure PerformMouseRightClicDownEvent(Canvas canvas, IPoint point, IEnumerable<IFigure> figures)
        {
            if (ClickCount < 1)
            {
                return Figure;
            }
            DrawFigureInCanvas(canvas, point);
            return CloseFigureDrawing();
        }

    }
}
